package com.osi.mes.qm.qtyEqu.bean;

import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.math.BigDecimal;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

import org.apache.commons.beanutils.BeanUtils;

import com.datasweep.compatibility.ui.Time;
import com.osi.mes.excel.BaseRowObject;
import com.osi.mes.excel.ExcelParserException;
import com.osi.mes.excel.ExcelPoiParser;
import com.osi.mes.qm.base.constants.IBasicConstants;
import com.osi.mes.utils.StringUtils;

public class QtyEquipment extends BaseRowObject{
	
	public String using_place;
	public String equ_name; 
	public String equ_model; 
	public String ship_no; 
	public String ship_cop_name;
	public Time ship_date;
	public Time purchase_time;
	public String measure_range;
	public String verification_scale;
	public String ship_cop_no;
	public String using_people;
	public Time verification_date;
	public Time expiration_date;
	public String certificate_type;
	public String certificate_no;
	public String vendor_tel;  
	public String contact_people; 
	public String contact_mail;
	public String fixed_asset_no;
	public String equ_type;
	public String mark;
	public Float equPrice;
	public String detect_frequence;
	public String equ_state;
	
	public String getUsing_place() {
		return using_place;
	}
	public void setUsing_place(String using_place) {
		this.using_place = using_place;
	}
	public String getEqu_name() {
		return equ_name;
	}
	public void setEqu_name(String equ_name) {
		this.equ_name = equ_name;
	}
	public String getEqu_model() {
		return equ_model;
	}
	public void setEqu_model(String equ_model) {
		this.equ_model = equ_model;
	}
	public String getShip_no() {
		return ship_no;
	}
	public void setShip_no(String ship_no) {
		this.ship_no = ship_no;
	}
	public String getShip_cop_name() {
		return ship_cop_name;
	}
	public void setShip_cop_name(String ship_cop_name) {
		this.ship_cop_name = ship_cop_name;
	}
	public Time getShip_date() {
		return ship_date;
	}
	
	public void setShip_date(Time ship_date) {
		this.ship_date = ship_date;
	}
	public Time getPurchase_time() {
		return purchase_time;
	}
	public void setPurchase_time(Time purchase_time) {
		this.purchase_time = purchase_time;
	}
	public String getMeasure_range() {
		return measure_range;
	}
	public void setMeasure_range(String measure_range) {
		this.measure_range = measure_range;
	}
	public String getVerification_scale() {
		return verification_scale;
	}
	public void setVerification_scale(String verification_scale) {
		this.verification_scale = verification_scale;
	}
	public String getShip_cop_no() {
		return ship_cop_no;
	}
	public void setShip_cop_no(String ship_cop_no) {
		this.ship_cop_no = ship_cop_no;
	}
	public String getUsing_people() {
		return using_people;
	}
	public void setUsing_people(String using_people) {
		this.using_people = using_people;
	}
	public Time getVerification_date() {
		return verification_date;
	}
	public void setVerification_date(Time verification_date) {
		this.verification_date = verification_date;
	}
	public Time getExpiration_date() {
			return expiration_date;
	}
	public void setExpiration_date(Time expiration_date) {
		this.expiration_date = expiration_date;
	}
	public String getCertificate_type() {
		return certificate_type;
	}
	public void setCertificate_type(String certificate_type) {
		this.certificate_type = certificate_type;
	}
	public String getCertificate_no() {
		return certificate_no;
	}
	public void setCertificate_no(String certificate_no) {
		this.certificate_no = certificate_no;
	}
	public String getVendor_tel() {
		return vendor_tel;
	}
	public void setVendor_tel(String vendor_tel) {
		this.vendor_tel = vendor_tel;
	}
	public String getContact_people() {
		return contact_people;
	}
	public void setContact_people(String contact_people) {
		this.contact_people = contact_people;
	}
	public String getContact_mail() {
		return contact_mail;
	}
	public void setContact_mail(String contact_mail) {
		this.contact_mail = contact_mail;
	}
	public String getFixed_asset_no() {
		return fixed_asset_no;
	}
	public void setFixed_asset_no(String fixed_asset_no) {
		this.fixed_asset_no = fixed_asset_no;
	}
	public String getEqu_type() {
		return equ_type;
	}
	public void setEqu_type(String equ_type) {
		this.equ_type = equ_type;
	}
	public String getMark() {
		return mark;
	}
	public void setMark(String mark) {
		this.mark = mark;
	}
	public Float getEquPrice() {
		if(equPrice!=null)
			return equPrice.floatValue();
		return new Float("0");
	}
	public void setEquPrice(Float equPrice) {
		this.equPrice = equPrice;
	}
	public String getDetect_frequence() {
		if(StringUtils.isNull(detect_frequence) )
			return  "0";
		
		if(detect_frequence.contains(IBasicConstants.UNIT_DETECT_FREQUENCE))
		{
			String detectFrequence = detect_frequence.replaceAll(IBasicConstants.UNIT_DETECT_FREQUENCE,"");
			detectFrequence = detectFrequence.trim();
			return  detectFrequence;
		}
		else
		{
			return  "0";
		}
	}
	public void setDetect_frequence(String detectFrequence) {
		this.detect_frequence = detectFrequence;
	}
	public String getEqu_state() {
		return equ_state;
	}
	public void setEqu_state(String equ_state) {
		this.equ_state = equ_state;
	}
	
	String[] properties = new String[]{
			"using_place","equ_name","equ_model","ship_no","ship_cop_name",
			"ship_date","purchase_time","measure_range","verification_scale",
			"ship_cop_no","using_people","detect_frequence","verification_date","expiration_date","certificate_type",
			"certificate_no","equPrice","vendor_tel","contact_people","contact_mail","fixed_asset_no","equ_type","mark",
			"equ_state"
	};
	
	@Override
	public String getPropertyName(int index) {
		if(index <0 || index >= properties.length)
			return null;
		
		return properties[index];
	}
	
	public static void main(String[] args) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
		String filePath = "E:\\质量设备台账.xls";
		QtyEquipment qty = new QtyEquipment();
		try {
			ExcelPoiParser.ingnoreTopRowNumber = 4;
			ExcelPoiParser.DATE_FORMAT1 = "M/dd/yyyy";
			List res = ExcelPoiParser.parseExcelFile(filePath, "com.osi.mes.qm.qtyEqu.bean.QtyEquipment");
			Float f = new Float("0");
			System.out.println("class : "+f.getClass().toString());
			if(res !=null)
			{
				System.out.println(res.size());
				for(int i=0;i<res.size();i++)
				{
					Object obj = res.get(i);
					for(int j=0;j<qty.properties.length;j++)
					{
						String time = BeanUtils.getProperty(obj, qty.properties[j]);
						System.out.println(qty.properties[j]+" : "+time);
					}
					
//					if(obj instanceof QtyEquipment)
//					{
//						QtyEquipment  qty = (QtyEquipment)obj;
//						System.out.print(qty.getUsing_place());
//						System.out.print("  "+qty.getEqu_name());
//						System.out.print("  "+qty.getEqu_model());
//						System.out.print("  "+qty.getShip_no());
//						System.out.print("  "+qty.getShip_cop_name());
//						System.out.print("  "+qty.getShip_date());
//						System.out.print("  "+qty.getPurchase_time());
//						System.out.print("  "+qty.getMeasure_range());
//						System.out.print("  "+qty.getVerification_scale());
//						System.out.print("  "+qty.getShip_cop_no());
//						System.out.print("  "+qty.getUsing_people());
//						System.out.print("  "+qty.getDetect_frequence());
//						System.out.print("  "+qty.getVerification_date());
//						System.out.print("  "+qty.getExpiration_date());
//						System.out.print("  "+qty.getCertificate_type());
//						System.out.print("  "+qty.getCertificate_no());
//						System.out.print("  "+qty.getMark());
//						System.out.print("  "+qty.getEquPrice());
//						System.out.println();
//						
//					}
				}
			}
		
		} catch (ExcelParserException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// S
			e.printStackTrace();
		}
	}
	@Override
	public int getPropertyCount() {
		if(properties == null)
			return 0;
		
		return properties.length;
	}
}
